package com.chart.web.controller.chart;
import com.chart.chart.service.IChartSettingsMenuService;
import com.chart.web.controller.chart.vo.ChartSettingsMenuVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.BeanUtils;
import java.util.List;
import java.util.stream.Collectors;

import java.util.List;

@RestController
@RequestMapping("/chartSettings")
public class ChartSettingsMenuController {

    @Autowired
    private IChartSettingsMenuService chartSettingsMenuService;

    @GetMapping("/list")
    public List<ChartSettingsMenuVO> list() {
        return chartSettingsMenuService.list().stream()
                //map 是一个流操作，用于将每个 ChartSettingsMenu 实体转换为 ChartSettingsMenuVO 对象。
                .map(entity -> {
                    ChartSettingsMenuVO vo = new ChartSettingsMenuVO();
                    BeanUtils.copyProperties(entity, vo);
                    return vo;
                })
                .collect(Collectors.toList());//Collectors.toList() 是一个收集器，将流的结果收集到一个列表中
    }








}
